import pytest
import logging
from config import BASE_PATH
from api.ihrm_login_api import IhrmLoginApi
from common.read_json import read_json_data
from common.assert_ihrm import AssertIhrm


class TestIhrmLogin(object):
    def setup_class(self):
        self.ihrmlogin = IhrmLoginApi()

    file_name = BASE_PATH + "/data/ihrm_login_data.json"
    login_data = read_json_data(file_name)

    @pytest.mark.parametrize("desc,req_body,status_code,success,code,message", login_data)
    def test_login(self, desc, req_body, status_code, success, code, message):
        resp = self.ihrmlogin.login(req_body)
        logging.info(f"“这是晚自习作业题的日志信息 , {desc}:{resp.json()}")
        # print(desc, resp.json())
        AssertIhrm.assert_ihrm(resp, status_code, success, code, message)
